﻿@model IEnumerable<MLManagement.Models.Customer>
@{
    ViewBag.Title = "Clientes";
    ViewBag.Criterio = String.Empty;
    ViewBag.TituloClientes = ((ViewBag.AreCustomersSelectable) ? "Seleccione un Cliente" : "Clientes");
    var grid = new WebGrid(Model, defaultSort: "MlUser", rowsPerPage: 50);
}
<div class="well">
    <h3>
        <p class="muted">
         @ViewBag.TituloClientes
         </p>
    </h3>
</div>
<p>
    @using (Html.BeginForm())
    {
        <input class="btn btn-info" type="submit" name="submit" value="Agregar Cliente" />
        <div class="pull-right">
            Buscar
            <input type="text" class="search-query" name="searchCriteria" />
            <input class="btn btn-info" type="submit" name="submit" value="Buscar Cliente" />
        </div>
        
        
    }
</p>
@{
    if (@ViewBag.AreCustomersSelectable == false)
    {
                                       
    @grid.GetHtml(
        tableStyle: "well",
        alternatingRowStyle: "alert alert-info",
        columns: grid.Columns(
            grid.Column("MlUser", "Usuario ML"),
            grid.Column("FirstName", "Nombre"),
            grid.Column("LastName", "Apellido"),
            grid.Column("Email", "E-mail", item => Html.Raw(String.Format("<a href=\"mailto:{0}\">{0}</a>", item.Email))),
            grid.Column("MobilePhone", "Teléfono móvil"),
            grid.Column("Phone", "Teléfono fijo"),
            grid.Column("Locality", "Ciudad o barrio"),
            grid.Column("Province", "Provincia"),
            grid.Column("Country", "País"),
            grid.Column(format: item => Html.Raw(Html.ActionLink("Editar", "Edit", new { id = item.CustomerID }) + " | " + Html.ActionLink("Eliminar", "Delete", new { id = item.CustomerID })))

                             )

            )
    }
    else
    {  
    @grid.GetHtml(
        tableStyle: "well",
        alternatingRowStyle: "alert alert-info",
        columns: grid.Columns(
            grid.Column("MlUser", "Usuario ML"),
            grid.Column("FirstName", "Nombre"),
            grid.Column("LastName", "Apellido"),
            grid.Column("Email", "E-mail", item => Html.Raw(String.Format("<a href=\"mailto:{0}\">{0}</a>", item.Email))),
            grid.Column("MobilePhone", "Teléfono móvil"),
            grid.Column("Phone", "Teléfono fijo"),
            grid.Column("Locality", "Ciudad o barrio"),
            grid.Column("Province", "Provincia"),
            grid.Column("Country", "País"),
            grid.Column(format: item => Html.ActionLink("Seleccionar", "Create", "Transaction", new { customerId = item.CustomerID },null))

                             )

            )
    }
}
